<?php
	require_once APPPATH . 'controllers/base_controllers/base_controller.php';

	class Mahasamadhi_registration extends Base_controller
	{
		public static $REGISTRATION_TEMPLATE = 'templates/registration/registration_template';		
		
		
		public function __construct()
		{
			parent::__construct();
			
			$this->load->model('values/mahasamadhi/Mahasamadhi_registration_value');
		}
		
		public function home( )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			
			$eventID = 1;
			
			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			
			$totnumreg = $this->Mahasamadhi_proxy->getTotalNumReg( $eventID, $curyear );
			if ($totnumreg > 1000)
			{
					//Maximum registration capacity reached
					$data['title'] = $curyear.' '.$this->Mahasamadhi_proxy->getEventName( $eventID ).' Sold Out';
					$data['msc_menu'] = TRUE;
					$data['msc_header'] = TRUE;
					$data['eventid'] = $eventID;
					$data['curyear'] = $curyear;		
					$data['view'] = 'mahasamadhi/home_page_ms_full_view';			
			}
			else
			{
				if ($this->Mahasamadhi_proxy->isEventValid( $eventID ))
				{
					switch ($eventID)
					{
						case 1:
							$data['title'] = $curyear.' '.$this->Mahasamadhi_proxy->getEventName( $eventID );
							$data['msc_menu'] = TRUE;
							$data['msc_header'] = TRUE;
							$data['eventid'] = $eventID;
							$data['curyear'] = $curyear;		
							$data['view'] = 'mahasamadhi/home_page_ms_view';
							//$data['view'] = 'mahasamadhi/home_page_ms_full_view';
							break;
						default:
							echo "Bad Event ID";
							die;
					}
				}
				else
				{
					//Event date has passed
					$data['title'] = $curyear.' '.$this->Mahasamadhi_proxy->getEventName( $eventID ).' Has Completed';
					$data['msc_menu'] = TRUE;
					$data['msc_header'] = TRUE;
					$data['eventid'] = $eventID;
					$data['curyear'] = $curyear;		
					$data['view'] = 'mahasamadhi/home_page_ms_closed_view';								
				}
			}
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function step1( $eventID )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			$this->load->model('values/mahasamadhi/Mahasamadhi_registration_value');
			
			$curyear = $this->Mahasamadhi_proxy->getEventYear();

			switch ($eventID)
			{
				case 1:
					//Get list of countries
					$country_list = $this->Walk_proxy->getCountryList();
					
					$data['title'] = 'Secure Registration for '.$this->Mahasamadhi_proxy->getEventName( $eventID )." ".$curyear;
					$data['msc_menu'] = TRUE;
					$data['msc_header'] = TRUE;
					$data['eventid'] = $eventID;
					$data['curyear'] = $curyear;
					$data['country_list'] = $country_list;
					$data['view'] = 'mahasamadhi/registration_ms_input_view';
					break;
				default:
					echo "Bad Event ID";
					die;
			}
		
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function step1_process( $eventID )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Paypal_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			$this->load->model('values/mahasamadhi/Mahasamadhi_registration_value');
			
			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			
			$currdt = strtotime("now");
			$criticaldt = strtotime("2012-04-30 23:59:59");

			switch ($eventID)
			{
				case 1:

					$ms_registration_value = new Mahasamadhi_registration_value();

					$regtype = intval($this->input->post('regtype'));
					$ms_registration_value->setRegistrationType( $regtype );
					$chykref = $this->input->post('chykref');
					$ms_registration_value->setCHYKRefFirstName("");
					$ms_registration_value->setCHYKRefLastName("");
					$chykCount = $this->input->post('numchyk');	
					$indCount = $this->input->post('numind');																
																								
					switch ($regtype)
					{
						case 1:
							$ms_registration_value->setRegistrationTypeDescription( "Individual" );
							if( isset( $_POST['regfeeind'] ) )
								$regcase = $this->input->post('regfeeind');
							else
								$regcase = 0;
							break;
						case 2:
							$ms_registration_value->setRegistrationTypeDescription( "Family" );
							if( isset( $_POST['regfeefam'] ) )
								$regcase = $this->input->post('regfeefam');
							else
								$regcase = 0;
							break;
						case 3:
							$ms_registration_value->setRegistrationTypeDescription( "CHYK" );
							if( isset( $_POST['regfeechyk'] ) )
								$regcase = $this->input->post('regfeechyk');
							else
								$regcase = 0;
							break;
					}
					
					$ms_registration_value->setRegistrationCase( $regcase );
					
					if ( isset( $_POST['needaccommodation'] ) )
						$nacc = $this->input->post('needaccommodation');
					else
						$nacc = 1;
					
					$ms_registration_value->setNeedAccommodation( $nacc );
					
					switch ($regcase)
					{
						//Double occupancy
						case 1:
							if ($regtype != 3)
							{
								if ($regtype == 2)
								{
									//Family
									if ($currdt <= $criticaldt) 
										$regfee = 1300;
									else 
										$regfee = 1450;
									if ($nacc == 0)
										$regfee = $regfee - $this->config->item('msc_accommodation_fee');
								}
								else
								{
									//Individual
									if ($indCount == 2)
									{
										if ($currdt <= $criticaldt) 
											$regfee = 1300;
										else 
											$regfee = 1450;
									}
									else
									{
										if ($indCount == 1)
										{
											if ($currdt <= $criticaldt) 
												$regfee = 650;
											else 
												$regfee = 725;
											}
										else
										{
											$regfee = 0;
										}						
									}					
									
									if ($nacc == 0)
										$regfee = $regfee - $this->config->item('msc_accommodation_fee');
								}
							}
							else
							{
								switch ($chykCount)
								{
									case 1:	
										if ($currdt <= $criticaldt) 
											$regfee = 585;
										else 
											$regfee = 652;
										break;
									case 2:	
										if ($currdt <= $criticaldt) 
											$regfee = 1170;
										else 
											$regfee = 1305;
										break;
								}
								if ($nacc == 0)
									$regfee = $regfee - $this->config->item('msc_accommodation_fee');
/*
								if ($currdt <= $criticaldt)
									$regfee = 1170;
								else
									$regfee = 1305;								
*/
						}
								
							$ms_registration_value->setRegistrationCaseDescription( "Double Occupancy" );
							break;
						//Triple occupancy
						case 2:
							if ($regtype != 3)
							{
								if ($currdt <= $criticaldt)
									$regfee = 1600;
								else
									$regfee = 1750;
								if ($nacc == 0)
									$regfee = $regfee - $this->config->item('msc_accommodation_fee');
							}
							else
							{
								switch ($chykCount)
								{
									case 1:	
										if ($currdt <= $criticaldt) 
											$regfee = 480;
										else 
											$regfee = 525;
										break;
									case 2:	
										if ($currdt <= $criticaldt) 
											$regfee = 960;
										else 
											$regfee = 1050;
										break;
									case 3:	
										if ($currdt <= $criticaldt) 
											$regfee = 1440;
										else 
											$regfee = 1575;
										break;
								}
								if ($nacc == 0)
									$regfee = $regfee - $this->config->item('msc_accommodation_fee');
							}

							$ms_registration_value->setRegistrationCaseDescription( "Triple Occupancy" );
							break;
						//Quad occupancy
						case 3:
							if ($regtype != 3)
							{
								if ($currdt <= $criticaldt)
									$regfee = 1750;
								else
									$regfee = 1900;
								if ($nacc == 0)
									$regfee = $regfee - $this->config->item('msc_accommodation_fee');
							}
							else
							{
								switch ($chykCount)
								{
									case 1:	
										if ($currdt <= $criticaldt) 
											$regfee = 394;
										else 
											$regfee = 427;
										break;
									case 2:	
										if ($currdt <= $criticaldt) 
											$regfee = 788;
										else 
											$regfee = 854;
										break;
									case 3:	
										if ($currdt <= $criticaldt) 
											$regfee = 1182;
										else 
											$regfee = 1281;
										break;
									case 4:	
										if ($currdt <= $criticaldt) 
											$regfee = 1575;
										else 
											$regfee = 1710;
										break;
								}
								if ($nacc == 0)
									$regfee = $regfee - $this->config->item('msc_accommodation_fee');
							}

							$ms_registration_value->setRegistrationCaseDescription( "Quad Occupancy" );
							break;
						//Single occupancy
						case 4:
							if ($currdt <= $criticaldt)
								$regfee = 1100;
							else
								$regfee = 1200;

							if ($nacc == 0)
								$regfee = $regfee - $this->config->item('msc_accommodation_fee');
							$ms_registration_value->setRegistrationCaseDescription( "Single Occupancy" );
							break;
					}
					
					$ms_registration_value->setRegistrationFee( $regfee );

					//Check if already registered
					if ($regtype != 3)
					{
						if ($regtype == 1)
						{
							$firstname = $this->input->post('indFN1');
							$lastname = $this->input->post('indLN1');						
						}
						else
						{
							$firstname = $this->input->post('adultFN1');
							$lastname = $this->input->post('adultLN1');													
						}
					}
					else
					{
						$firstname = $this->input->post('chykFN1');
						$lastname = $this->input->post('chykFN1');
					}
					
					//echo "Reg Type: ".$regtype.", FN: ".$firstname.", LN: ".$lastname."</br>";
					//die;
					
					if ($this->Mahasamadhi_proxy->isEventRegistered( $eventID, $firstname, $lastname, $this->input->post('email')))
					{
						redirect( base_url() . 'mahasamadhi/mahasamadhi_registration/event_registered/'.$eventID);
					}
									
					$ms_registration_value->setEventID($eventID);
					$ms_registration_value->setCurrentYear($curyear);
					$ms_registration_value->setEmail($this->input->post('email'));
					$ms_registration_value->setPhone($this->input->post('phoneNumber'));
					$ms_registration_value->setAddress($this->input->post('address'));
					$ms_registration_value->setAddress1($this->input->post('address1'));
					$ms_registration_value->setCity($this->input->post('city'));
					$ms_registration_value->setCountry($this->input->post('country'));					
					if ($this->input->post('country') == "US")
					{
						$ms_registration_value->setState($this->input->post('stateusa'));
					}
					else
					{
						$ms_registration_value->setState($this->input->post('stateglobal'));						
					}

					$ms_registration_value->setZip($this->input->post('zip'));
					
					if ($regtype != 3)
					{
						if ($regtype == 1)
						{
							$numind = intval($this->input->post('numind'));
							$ms_registration_value->setNumAdultRegistered($numind);	
							$ms_registration_value->setIsTeacher( intval($this->input->post('isteacherind')) );						
						}
						else
						{
							$numadult = intval($this->input->post('numadult'));
							$ms_registration_value->setNumAdultRegistered($this->input->post('numadult'));
							$ms_registration_value->setIsTeacher( intval($this->input->post('isteacherfam')) );						
						}
					}
					
					//$numchild = intval($this->input->post('numchild'));
					$numchild = intval($this->input->post('numchild'));
					$numchyk = intval($this->input->post('numchyk'));

					$adultInfoArr = array();
					$childInfoArr = array();
					$chykInfoArr = array();
					$numchildren = 0;
					$numchyks = 0;
					
					if ($regtype != 3)
					{
						if ($regtype == 1)
						{
							//Individual
							for($idxa=1; $idxa <= $numind; $idxa++)
							{
								$adultRec = array();
		
								if ($idxa == 1)
								{
									$ms_registration_value->setFirstName($this->input->post('indFN'.$idxa));
									$ms_registration_value->setLastName($this->input->post('indLN'.$idxa));
									//echo $ms_registration_value->getFirstName()." ".$ms_registration_value->getLastName()."</br>";
									//die;
								}
								
								$adultRec["firstname"] = $this->input->post('indFN'.$idxa);
								$adultRec["lastname"] = $this->input->post('indLN'.$idxa);
								$adultRec["gender"] = $this->input->post('indG'.$idxa);
								
								$idietrest = "";
								if( isset( $_POST['idietrest'.$idxa.'1'] ) )
								{
									$idietrest = "Low Sugar";
								}
								if( isset( $_POST['idietrest'.$idxa.'2'] ) )
								{
									if ($idietrest != "") $idietrest =  $idietrest.",Low Fat"; else $idietrest =  "Low Fat";
								}
								if( isset( $_POST['idietrest'.$idxa.'3'] ) )
								{
									if ($idietrest != "")  $idietrest =  $idietrest.",Gluten Free"; else $idietrest = "Gluten Free";
								}
		
								$adultRec["dietrest"] = $idietrest;
								//$adultRec["allergies"] = $this->input->post('ia'.$idxa);
								$adultRec["allergies"] = "none";
		
								array_push($adultInfoArr, $adultRec);						
							}
							$ms_registration_value->setAdultInfo($adultInfoArr);
						}
						else
						{
							//Family
							for($idxa=1; $idxa <= $numadult; $idxa++)
							{
								$adultRec = array();
		
								if ($idxa == 1)
								{
									$ms_registration_value->setFirstName($this->input->post('adultFN'.$idxa));
									$ms_registration_value->setLastName($this->input->post('adultLN'.$idxa));						
									//echo $ms_registration_value->getFirstName()." ".$ms_registration_value->getLastName()."</br>";
									//die;
								}
								
								$adultRec["firstname"] = $this->input->post('adultFN'.$idxa);
								$adultRec["lastname"] = $this->input->post('adultLN'.$idxa);
								$adultRec["gender"] = $this->input->post('adultG'.$idxa);
								
								$adietrest = "";
								if( isset( $_POST['adietrest'.$idxa.'1'] ) )
								{
									$adietrest = "Low Sugar";
								}
								if( isset( $_POST['adietrest'.$idxa.'2'] ) )
								{
									if ($adietrest != "") $adietrest =  $adietrest.",Low Fat"; else $adietrest =  "Low Fat";
								}
								if( isset( $_POST['adietrest'.$idxa.'3'] ) )
								{
									if ($adietrest != "")  $adietrest =  $adietrest.",Gluten Free"; else $adietrest = "Gluten Free";
								}
		
								$adultRec["dietrest"] = $adietrest;
								//$adultRec["allergies"] = $this->input->post('aa'.$idxa);
								$adultRec["allergies"] = "none";
		
								array_push($adultInfoArr, $adultRec);						
							}
						}
						$ms_registration_value->setAdultInfo($adultInfoArr);

						for($idxc=1; $idxc <= $numchild; $idxc++)
						{
							$childRec = array();
							$childRec["firstname"] = $this->input->post('childFN'.$idxc);
							$childRec["lastname"] = $this->input->post('childLN'.$idxc);
							$childRec["gender"] = $this->input->post('childG'.$idxc);
							$childRec["age"] = $this->input->post('childAge'.$idxc);
							
							$cdietrest = "";
							if( isset( $_POST['cdietrest'.$idxc.'1'] ) )
							{
								$cdietrest = "Low Sugar";
							}
							if( isset( $_POST['cdietrest'.$idxc.'2'] ) )
							{
								if ($cdietrest != "") $cdietrest =  $cdietrest.",Low Fat"; else $cdietrest =  "Low Fat";
							}
							if( isset( $_POST['cdietrest'.$idxc.'3'] ) )
							{
								if ($cdietrest != "")  $cdietrest =  $cdietrest.",Gluten Free"; else $cdietrest = "Gluten Free";
							}
		
							$childRec["dietrest"] = $cdietrest;
							//$childRec["allergies"] = $this->input->post('ca'.$idxc);
							$childRec["allergies"] = "none";
	
							if( isset( $_POST['ischyk'.$idxc] ) )
							{
								$childRec["ischyk"] = 1;
								array_push($chykInfoArr, $childRec);
								$numchyks += 1;
							}
							else
							{							
								$childRec["ischyk"] = 0;
								array_push($childInfoArr, $childRec);
								$numchildren += 1;
							}
						}
						$ms_registration_value->setNumChildRegistered($numchildren);
						$ms_registration_value->setChildInfo($childInfoArr);
					}
					else
					{
						//CHYK
						for($idxa=1; $idxa <= $numchyk; $idxa++)
						{
							$chykRec = array();
	
							if ($idxa == 1)
							{
								$ms_registration_value->setFirstName($this->input->post('chykFN'.$idxa));
								$ms_registration_value->setLastName($this->input->post('chykLN'.$idxa));
								if ($chykref == "yes")
								{
									$ms_registration_value->setCHYKRefFirstName($this->input->post('chykRefFN'));
									$ms_registration_value->setCHYKRefLastName($this->input->post('chykRefLN'));								
								}
								//echo $ms_registration_value->getFirstName()." ".$ms_registration_value->getLastName()."</br>";
								//die;
							}
							
							$chykRec["firstname"] = $this->input->post('chykFN'.$idxa);
							$chykRec["lastname"] = $this->input->post('chykLN'.$idxa);
							$chykRec["gender"] = $this->input->post('chykG'.$idxa);
							
							$chdietrest = "";
							if( isset( $_POST['chdietrest'.$idxa.'1'] ) )
							{
								$chdietrest = "Low Sugar";
							}
							if( isset( $_POST['chdietrest'.$idxa.'2'] ) )
							{
								if ($chdietrest != "") $chdietrest =  $chdietrest.",Low Fat"; else $chdietrest =  "Low Fat";
							}
							if( isset( $_POST['chdietrest'.$idxa.'3'] ) )
							{
								if ($chdietrest != "")  $chdietrest =  $chdietrest.",Gluten Free"; else $chdietrest = "Gluten Free";
							}
	
							$chykRec["dietrest"] = $chdietrest;
							//$chykRec["allergies"] = $this->input->post('cha'.$idxa);
							$chykRec["allergies"] = "none";
	
							array_push($chykInfoArr, $chykRec);
							
							$numchyks += 1;						
						}
						//$ms_registration_value->setNumCHYKRegistered($numchyks);
						//$ms_registration_value->setCHYKInfo($chykInfoArr);						
					}
					$ms_registration_value->setNumCHYKRegistered($numchyks);
					$ms_registration_value->setCHYKInfo($chykInfoArr);						
					
					$bikshaInfoArr = array();
					$numbiksha = 0;
					for($id = 0; $id < 5; $id++)
					{
						for($ie = 0; $ie < 3; $ie++)
						{
							$tag = strval(($id+1).($ie+1));
							if( isset( $_POST['boption'.$tag] ))
							{
								$bikshaRec = array();
		
								$bikshaRec["dayid"] = strval($id+1);
								$bikshaRec["eventid"] = strval($ie+1);
								
								array_push($bikshaInfoArr, $bikshaRec);
								
								$numbiksha++;
							}
						}
					}
					$ms_registration_value->setNumBiksha($numbiksha);
					$ms_registration_value->setBikshaInfo($bikshaInfoArr);
					
					$arathiInfoArr = array();
					$numarathi = 0;
					for($id = 0; $id < 5; $id++)
					{
						for($ie = 0; $ie < 3; $ie++)
						{
							$tag = strval(($id+1).($ie+1));
							if( isset( $_POST['aoption'.$tag] ))
							{
								$arathiRec = array();
		
								$arathiRec["dayid"] = strval($id+1);
								$arathiRec["eventid"] = strval($ie+1);
								
								array_push($arathiInfoArr, $arathiRec);
								
								$numarathi++;
							}
						}
					}
					$ms_registration_value->setNumArathi($numarathi);
					$ms_registration_value->setArathiInfo($arathiInfoArr);
					
					if (is_numeric($this->input->post('donationamount')))
						$donationamount = floatval($this->input->post('donationamount'));
					else
						$donationamount = 0;
						
					$bhiksha_fee = $this->Mahasamadhi_proxy->getBhiksaFee( $eventID );
					$arathi_fee = $this->Mahasamadhi_proxy->getArathiFee( $eventID );
					
					$sponsoramount = ($numbiksha*$bhiksha_fee) + ($numarathi*$arathi_fee);
					$ms_registration_value->setSponsorship($sponsoramount);
					$ms_registration_value->setDonation($donationamount);
					$ms_registration_value->setAmountCommitted( ($regfee + $sponsoramount + $donationamount - (100*$ms_registration_value->getIsTeacher())) );										
					
					if( isset( $_POST['snwc'] ))
					{
						$ms_registration_value->setSpecialNeedsWheelchair(1);
					}
					else
					{
						$ms_registration_value->setSpecialNeedsWheelchair(0);
					}
					
					if( isset( $_POST['snrm'] ))
					{
						$ms_registration_value->setSpecialNeedsRoom(1);
					}
					else
					{
						$ms_registration_value->setSpecialNeedsRoom(0);
					}

					$ms_registration_value->setSpecialRequests($this->input->post('sncomments'));

					//echo $ms_registration_value->getTotalRegistrationFee().'</br>';
					//die;

					break;
				default:
					echo "Bad Event ID";
					die;
			}

			//echo $ms_registration_value->getNumBiksha().'</br>';
			//echo $ms_registration_value->getNumArathi().'</br>';
			//die;

			//Create session variable
			$this->session->unset_userdata('ms_registration_value');
			$this->session->set_userdata('ms_registration_value', serialize($ms_registration_value));
			
			if ($this->session->userdata('sessionobj_temp_id') != "")
			{
				//There is already a session variable, update with new object
				$paypalTempId = $this->session->userdata('sessionobj_temp_id');
				if ($paypalTempId <= 0)
				{
					redirect( base_url() . 'mahasamadhi/mahasamadhi_registration/registration_error/');
				}				
				$this->Paypal_proxy->updateTempData( $paypalTempId, serialize($ms_registration_value) );
			}
			else
			{
				//No session variable
				$paypalTempId = $this->Paypal_proxy->addTempData( serialize($ms_registration_value) );
				if ($paypalTempId <= 0)
				{
					redirect( base_url() . 'mahasamadhi/mahasamadhi_registration/registration_error/');
				}
				$this->session->set_userdata('sessionobj_temp_id', $paypalTempId);				
			}
			
			//echo "Temp ID: ".$paypalTempId.'</br>';
			//die;
			
			$numtotreg = $ms_registration_value->getTotalNumRegistered();
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID ).' '.$curyear;

			$data['title'] = $desc.' Registration Summary';
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_registration_summary_view';
			$data['ms_registration_value'] = $ms_registration_value;
			$data['paypal_form'] = $this->getPayPalForm( $ms_registration_value, $numtotreg, $paypalTempId, $desc, $eventID );
			$data['eventid'] = $eventID;
			
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		//Invoke view to present a list of registrations to edit
		public function admin_edit_ms_registrations( $adminUrlKey )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Person_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			$this->load->model('values/mahasamadhi/Mahasamadhi_registration_value');
			
			$is_logged_in = $this->session->userdata( 'is_logged_in' );
			if (!$is_logged_in)
			{
				redirect( base_url() . 'cmb/member/login_home/' );
			}
			
			//Get id for person who logged in
			$loginPersonId = $this->session->userdata( 'person_id' );
			if ( $loginPersonId < 1 )
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );
			if ($seckey != $this->session->userdata( 'logged_in_key' ))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			$this->session->unset_userdata( 'member_logged_in_key' );
			
			$this->session->set_userdata( 'admin_url_key', $adminUrlKey );
			$this->session->set_userdata( 'admin_sec_key', $seckey );

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$desc = $this->Mahasamadhi_proxy->getEventName( 1 );
			
			$regInfo = $this->Mahasamadhi_proxy->getAllMahasamadhiRegistrations( $curyear );			
/*			
			echo count($regInfo)."</br>";
			die;
*/
			$data['title'] = ' Admin Edit Registrations for '.$desc.' '.$curyear;
			//$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['curyear'] = $curyear;
			$data['view'] = 'mahasamadhi/admin_edit_ms_registrations_view';
			$data['regInfo'] = $regInfo;
			$data['urlKey'] = $adminUrlKey;
			$data['loggedinname'] = $this->Person_proxy->getPersonName( $loginPersonId );
			
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		//Process submit from a specific selection from "admin_edit_ms_registrations_view"
		//and invoke "admin_edit_mahasamadhi_registration_view" to edit that registration
		public function admin_edit_ms_registration_process( $ms_reg_history_id, $urlKey )
		{
			$eventID = 1;
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Person_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			$this->load->model('values/mahasamadhi/Mahasamadhi_registration_value');
			
			$is_logged_in = $this->session->userdata( 'is_logged_in' );
			if (!$is_logged_in)
			{
				redirect( base_url() . 'cmb/member/login_home/' );
			}
		
			$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );
			if ($seckey != $this->session->userdata( 'logged_in_key' ))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}
			
			//Get id for person who logged in
			$loginPersonId = $this->session->userdata( 'person_id' );
			if ( $loginPersonId < 1 )
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			if ((!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "mahasamadhi", "admin" )) and (!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "admin" )) and (!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "superadmin" )))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );				
			}

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$desc = $this->Mahasamadhi_proxy->getEventName( 1 );
			
			//Get registration value object
			$ms_registration_value = $this->Mahasamadhi_proxy->getRegistrantDetailInfo( $ms_reg_history_id );
			
			if ($ms_registration_value->getCHYKRefFirstName() != "")
				$chykrefflg = "yes";
			else
				$chykrefflg = "no";
			
			//echo "Registration Type: ".$ms_registration_value->getRegistrationType()."</br>";
			//die;
												
			$country_list = $this->Walk_proxy->getCountryList();

			$data['title'] = ' Admin Edit Registration for '.$desc.' '.$curyear;
			//$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['curyear'] = $this->Mahasamadhi_proxy->getEventYear();
			$data['view'] = 'mahasamadhi/admin_edit_mahasamadhi_registration_view';
			$data['ms_registration_value'] = $ms_registration_value;
			$data['ms_reg_history_id'] = $ms_reg_history_id;
			$data['adminUrlKey'] = $this->session->userdata( 'admin_url_key' );
			$data['loggedinname'] = $this->Person_proxy->getPersonName( $loginPersonId );
			$data['country_list'] = $country_list;
			$data['eventid'] = $eventID;
			$data['chykrefflg'] = $chykrefflg;
			$data['urlKey'] = $urlKey;
						
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		//Process submit from "admin_edit_mahasamadhi_registration_view"
		public function admin_edit_mahasamadhi_registration_process( $ms_reg_history_id, $urlKey )
		{
			$eventID = 1;
			$this->load->model('proxies/Person_proxy');
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			$this->load->model('values/mahasamadhi/Mahasamadhi_registration_value');
			$this->load->library('encrypt');
			
			$is_logged_in = $this->session->userdata( 'is_logged_in' );
			if (!$is_logged_in)
			{
				echo "Admin is not logged in";
				die;
				redirect( base_url() . 'cmb/member/login_home/' );
			}
			
			$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );
			if ($seckey != $this->session->userdata( 'logged_in_key' ))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}
			
			//Get id for person who logged in
			$loginPersonId = $this->session->userdata( 'person_id' );
			if ( $loginPersonId < 1 )
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			if ((!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "mahasamadhi", "admin" )) and (!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "admin" )) and (!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "superadmin" )))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );				
			}

			$curyear = $this->Mahasamadhi_proxy->getEventYear();

			$ms_registration_value_orig = $this->Mahasamadhi_proxy->getRegistrantDetailInfo($ms_reg_history_id);
			$ms_registration_value = $this->Mahasamadhi_proxy->getRegistrantDetailInfo($ms_reg_history_id);
									
			//Have to set date to when original registration was created.
			//$currdt = strtotime("now");
			$currdt = strtotime($this->Mahasamadhi_proxy->getRegistrationCreateDate($ms_reg_history_id, $curyear));
			$criticaldt = strtotime("2012-04-30 23:59:59");

			$regtype = $this->input->post('regtype');
			if ($regtype == "")
			{
				echo("<b>MUST SPECIFY A REGISTRATION TYPE</b>");
				die;				
			}
			
			switch ($regtype)
			{
				case 1:
					if( isset( $_POST['regcaseind'] ) )
						$regcase = $this->input->post('regcaseind');
					else
						$regcase = 0;
			
					break;
				case 2:
					if( isset( $_POST['regcasefam'] ) )
						$regcase = $this->input->post('regcasefam');
					else
						$regcase = 0;
			
					break;
				case 3:
					if( isset( $_POST['regcasechyk'] ) )
						$regcase = $this->input->post('regcasechyk');
					else
						$regcase = 0;
			
					break;
			}
			
			$ms_registration_value->setRegistrationType( $regtype );
			$ms_registration_value->setRegistrationCase( $regcase );
			$chykref = $this->input->post('chykref');
			$ms_registration_value->setCHYKRefFirstName("");
			$ms_registration_value->setCHYKRefLastName("");																
			$chykCount = $this->input->post('numchyk');																
			$indCount = $this->input->post('numind');																
						
			switch ($regtype)
			{
				case 1:
					$ms_registration_value->setRegistrationTypeDescription( "Individual" );
					break;
				case 2:
					$ms_registration_value->setRegistrationTypeDescription( "Family" );
					break;
				case 3:
					$ms_registration_value->setRegistrationTypeDescription( "CHYK" );
					break;
			}
						
			if ( isset( $_POST['needaccommodation'] ) )
				$nacc = $this->input->post('needaccommodation');
			else
				$nacc = 1;
			
			$ms_registration_value->setNeedAccommodation( $nacc );
			switch ($regcase)
			{
				//Double occupancy
				case 1:
					if ($regtype != 3)
					{
						if ($regtype == 2)
						{
							//Family
							if ($currdt <= $criticaldt) 
								$regfee = 1300;
							else 
								$regfee = 1450;
							if ($nacc == 0)
								$regfee = $regfee - $this->config->item('msc_accommodation_fee');
						}
						else
						{
							//Individual
							if ($indCount == 2)
							{
								if ($currdt <= $criticaldt) 
									$regfee = 1300;
								else 
									$regfee = 1450;
							}
							else
							{
								if ($indCount == 1)
								{
									if ($currdt <= $criticaldt) 
										$regfee = 650;
									else 
										$regfee = 725;
									}
								else
								{
									$regfee = 0;
								}						
							}					
							
							if ($nacc == 0)
								$regfee = $regfee - $this->config->item('msc_accommodation_fee');
						}
					}
					else
					{
						switch ($chykCount)
						{
							case 1:	
								if ($currdt <= $criticaldt) 
									$regfee = 585;
								else 
									$regfee = 652;
								break;
							case 2:	
								if ($currdt <= $criticaldt) 
									$regfee = 1170;
								else 
									$regfee = 1305;
								break;
						}
/*
								if ($currdt <= $criticaldt)
									$regfee = 1170;
								else
									$regfee = 1305;								
*/
						if ($nacc == 0)
							$regfee = $regfee - $this->config->item('msc_accommodation_fee');
				}
						
					$ms_registration_value->setRegistrationCaseDescription( "Double Occupancy" );
					break;
				//Triple occupancy
				case 2:
					if ($regtype != 3)
					{
						if ($currdt <= $criticaldt)
							$regfee = 1600;
						else
							$regfee = 1750;
						if ($nacc == 0)
							$regfee = $regfee - $this->config->item('msc_accommodation_fee');
					}
					else
					{
						switch ($chykCount)
						{
							case 1:	
								if ($currdt <= $criticaldt) 
									$regfee = 480;
								else 
									$regfee = 525;
								break;
							case 2:	
								if ($currdt <= $criticaldt) 
									$regfee = 960;
								else 
									$regfee = 1050;
								break;
							case 3:	
								if ($currdt <= $criticaldt) 
									$regfee = 1440;
								else 
									$regfee = 1575;
								break;
						}
						if ($nacc == 0)
							$regfee = $regfee - $this->config->item('msc_accommodation_fee');
					}

					$ms_registration_value->setRegistrationCaseDescription( "Triple Occupancy" );
					break;
				//Quad occupancy
				case 3:
					if ($regtype != 3)
					{
						if ($currdt <= $criticaldt)
							$regfee = 1750;
						else
							$regfee = 1900;
						if ($nacc == 0)
							$regfee = $regfee - $this->config->item('msc_accommodation_fee');
												}
					else
					{
						switch ($chykCount)
						{
							case 1:	
								if ($currdt <= $criticaldt) 
									$regfee = 394;
								else 
									$regfee = 427;
								break;
							case 2:	
								if ($currdt <= $criticaldt) 
									$regfee = 788;
								else 
									$regfee = 854;
								break;
							case 3:	
								if ($currdt <= $criticaldt) 
									$regfee = 1182;
								else 
									$regfee = 1281;
								break;
							case 4:	
								if ($currdt <= $criticaldt) 
									$regfee = 1575;
								else 
									$regfee = 1710;
								break;
						}
						if ($nacc == 0)
							$regfee = $regfee - $this->config->item('msc_accommodation_fee');
					}

					$ms_registration_value->setRegistrationCaseDescription( "Quad Occupancy" );
					break;
				//Single occupancy
				case 4:
					if ($currdt <= $criticaldt)
						$regfee = 1100;
					else
						$regfee = 1200;

					if ($nacc == 0)
						$regfee = $regfee - $this->config->item('msc_accommodation_fee');
					$ms_registration_value->setRegistrationCaseDescription( "Single Occupancy" );
					break;
			}
			
			$ms_registration_value->setRegistrationFee( $regfee );							
			$ms_registration_value->setEventID($eventID);
			$ms_registration_value->setCurrentYear($curyear);
			$ms_registration_value->setEmail($this->input->post('email'));
			$ms_registration_value->setPhone($this->input->post('phoneNumber'));
			$ms_registration_value->setAddress($this->input->post('address'));
			$ms_registration_value->setAddress1($this->input->post('address1'));
			$ms_registration_value->setCity($this->input->post('city'));
			$ms_registration_value->setCountry($this->input->post('country'));					
			if ($this->input->post('country') == "US")
			{
				$ms_registration_value->setState($this->input->post('stateusa'));
			}
			else
			{
				$ms_registration_value->setState($this->input->post('stateglobal'));						
			}

			$ms_registration_value->setZip($this->input->post('zip'));
			
			if ($regtype != 3)
			{
				if ($regtype == 1)
				{
					$numind = intval($this->input->post('numind'));
					$ms_registration_value->setNumAdultRegistered($numind);							
					$ms_registration_value->setIsTeacher( intval($this->input->post('isteacherind')) );						
				}
				else
				{
					$numadult = intval($this->input->post('numadult'));
					$ms_registration_value->setNumAdultRegistered($this->input->post('numadult'));
					$ms_registration_value->setIsTeacher( intval($this->input->post('isteacherfam')) );						
				}
			}
			
			$numchild = intval($this->input->post('numchild'));
			$numchyk = intval($this->input->post('numchyk'));

			$adultInfoArr = array();
			$childInfoArr = array();
			$chykInfoArr = array();
			$numchildren = 0;
			$numchyks = 0;
			
			if ($regtype != 3)
			{
				if ($regtype == 1)
				{
					//Individual
					for($idxa=1; $idxa <= $numind; $idxa++)
					{
						$adultRec = array();

						if ($idxa == 1)
						{
							$ms_registration_value->setFirstName($this->input->post('indFN'.$idxa));
							$ms_registration_value->setLastName($this->input->post('indLN'.$idxa));
						}
						
						$adultRec["firstname"] = $this->input->post('indFN'.$idxa);
						$adultRec["lastname"] = $this->input->post('indLN'.$idxa);
						$adultRec["gender"] = $this->input->post('indG'.$idxa);
						
						$idietrest = "";
						if( isset( $_POST['idietrest'.$idxa.'1'] ) )
						{
							$idietrest = "Low Sugar";
						}
						if( isset( $_POST['idietrest'.$idxa.'2'] ) )
						{
							if ($idietrest != "") $idietrest =  $idietrest.",Low Fat"; else $idietrest =  "Low Fat";
						}
						if( isset( $_POST['idietrest'.$idxa.'3'] ) )
						{
							if ($idietrest != "")  $idietrest =  $idietrest.",Gluten Free"; else $idietrest = "Gluten Free";
						}

						$adultRec["dietrest"] = $idietrest;
						//$adultRec["allergies"] = $this->input->post('ia'.$idxa);
						$adultRec["allergies"] = "none";

						array_push($adultInfoArr, $adultRec);						
					}
					$ms_registration_value->setAdultInfo($adultInfoArr);
				}
				else
				{
					//Family
					for($idxa=1; $idxa <= $numadult; $idxa++)
					{
						$adultRec = array();

						if ($idxa == 1)
						{
							$ms_registration_value->setFirstName($this->input->post('adultFN'.$idxa));
							$ms_registration_value->setLastName($this->input->post('adultLN'.$idxa));						
						}
						
						$adultRec["firstname"] = $this->input->post('adultFN'.$idxa);
						$adultRec["lastname"] = $this->input->post('adultLN'.$idxa);
						$adultRec["gender"] = $this->input->post('adultG'.$idxa);
						
						$adietrest = "";
						if( isset( $_POST['adietrest'.$idxa.'1'] ) )
						{
							$adietrest = "Low Sugar";
						}
						if( isset( $_POST['adietrest'.$idxa.'2'] ) )
						{
							if ($adietrest != "") $adietrest =  $adietrest.",Low Fat"; else $adietrest =  "Low Fat";
						}
						if( isset( $_POST['adietrest'.$idxa.'3'] ) )
						{
							if ($adietrest != "")  $adietrest =  $adietrest.",Gluten Free"; else $adietrest = "Gluten Free";
						}

						$adultRec["dietrest"] = $adietrest;
						//$adultRec["allergies"] = $this->input->post('aa'.$idxa);
						$adultRec["allergies"] = "none";

						array_push($adultInfoArr, $adultRec);						
					}
				}
				$ms_registration_value->setAdultInfo($adultInfoArr);

				for($idxc=1; $idxc <= $numchild; $idxc++)
				{
					$childRec = array();
					$childRec["firstname"] = $this->input->post('childFN'.$idxc);
					$childRec["lastname"] = $this->input->post('childLN'.$idxc);
					$childRec["gender"] = $this->input->post('childG'.$idxc);
					$childRec["age"] = $this->input->post('childAge'.$idxc);
					
					$cdietrest = "";
					if( isset( $_POST['cdietrest'.$idxc.'1'] ) )
					{
						$cdietrest = "Low Sugar";
					}
					if( isset( $_POST['cdietrest'.$idxc.'2'] ) )
					{
						if ($cdietrest != "") $cdietrest =  $cdietrest.",Low Fat"; else $cdietrest =  "Low Fat";
					}
					if( isset( $_POST['cdietrest'.$idxc.'3'] ) )
					{
						if ($cdietrest != "")  $cdietrest =  $cdietrest.",Gluten Free"; else $cdietrest = "Gluten Free";
					}
	
					$childRec["dietrest"] = $cdietrest;
					//$childRec["allergies"] = $this->input->post('ca'.$idxc);
					$childRec["allergies"] = "none";
	
					if( isset( $_POST['ischyk'.$idxc] ) )
					{
						$childRec["ischyk"] = 1;
						array_push($chykInfoArr, $childRec);
						$numchyks += 1;
					}
					else
					{							
						$childRec["ischyk"] = 0;
						array_push($childInfoArr, $childRec);
						$numchildren += 1;
					}
				}
				$ms_registration_value->setNumChildRegistered($numchildren);
				$ms_registration_value->setChildInfo($childInfoArr);
			}
			else
			{
				//CHYK
				for($idxa=1; $idxa <= $numchyk; $idxa++)
				{
					$chykRec = array();
	
					if ($idxa == 1)
					{
						$ms_registration_value->setFirstName($this->input->post('chykFN'.$idxa));
						$ms_registration_value->setLastName($this->input->post('chykLN'.$idxa));
						if ($chykref == "yes")
						{
							$ms_registration_value->setCHYKRefFirstName($this->input->post('chykRefFN'));
							$ms_registration_value->setCHYKRefLastName($this->input->post('chykRefLN'));								
						}
						//echo $ms_registration_value->getFirstName()." ".$ms_registration_value->getLastName()."</br>";
						//die;
					}
					
					$chykRec["firstname"] = $this->input->post('chykFN'.$idxa);
					$chykRec["lastname"] = $this->input->post('chykLN'.$idxa);
					$chykRec["gender"] = $this->input->post('chykG'.$idxa);
					
					$chdietrest = "";
					if( isset( $_POST['chdietrest'.$idxa.'1'] ) )
					{
						$chdietrest = "Low Sugar";
					}
					if( isset( $_POST['chdietrest'.$idxa.'2'] ) )
					{
						if ($chdietrest != "") $chdietrest =  $chdietrest.",Low Fat"; else $chdietrest =  "Low Fat";
					}
					if( isset( $_POST['chdietrest'.$idxa.'3'] ) )
					{
						if ($chdietrest != "")  $chdietrest =  $chdietrest.",Gluten Free"; else $chdietrest = "Gluten Free";
					}
	
					$chykRec["dietrest"] = $chdietrest;
					//$chykRec["allergies"] = $this->input->post('cha'.$idxa);
					$chykRec["allergies"] = "none";
	
					array_push($chykInfoArr, $chykRec);
					
					$numchyks += 1;						
				}
				//$ms_registration_value->setNumCHYKRegistered($numchyks);
				//$ms_registration_value->setCHYKInfo($chykInfoArr);			
			}
			$ms_registration_value->setNumCHYKRegistered($numchyks);
			$ms_registration_value->setCHYKInfo($chykInfoArr);			

			$bikshaInfoArr = array();
			$numbiksha = 0;
			for($id = 0; $id < 5; $id++)
			{
				for($ie = 0; $ie < 3; $ie++)
				{
					$tag = strval(($id+1).($ie+1));
					if( isset( $_POST['boption'.$tag] ))
					{
						$bikshaRec = array();

						$bikshaRec["dayid"] = strval($id+1);
						$bikshaRec["eventid"] = strval($ie+1);
						
						array_push($bikshaInfoArr, $bikshaRec);
						
						$numbiksha++;
					}
				}
			}
			$ms_registration_value->setNumBiksha($numbiksha);
			$ms_registration_value->setBikshaInfo($bikshaInfoArr);
			
			$arathiInfoArr = array();
			$numarathi = 0;
			for($id = 0; $id < 5; $id++)
			{
				for($ie = 0; $ie < 3; $ie++)
				{
					$tag = strval(($id+1).($ie+1));
					if( isset( $_POST['aoption'.$tag] ))
					{
						$arathiRec = array();

						$arathiRec["dayid"] = strval($id+1);
						$arathiRec["eventid"] = strval($ie+1);
						
						array_push($arathiInfoArr, $arathiRec);
						
						$numarathi++;
					}
				}
			}
			$ms_registration_value->setNumArathi($numarathi);
			$ms_registration_value->setArathiInfo($arathiInfoArr);
			
			if (is_numeric($this->input->post('donationamount')))
				$donationamount = floatval($this->input->post('donationamount'));
			else
				$donationamount = 0;
				
			if (is_numeric($this->input->post('discountamount')))
				$discountamount = floatval($this->input->post('discountamount'));
			else
				$discountamount = 0;

			$bhiksha_fee = $this->Mahasamadhi_proxy->getBhiksaFee( $eventID );
			$arathi_fee = $this->Mahasamadhi_proxy->getArathiFee( $eventID );
			
			$sponsoramount = ($numbiksha*$bhiksha_fee) + ($numarathi*$arathi_fee);
			$ms_registration_value->setSponsorship($sponsoramount);
			$ms_registration_value->setDonation($donationamount);
			$ms_registration_value->setGeneralDiscount($discountamount);
			$ms_registration_value->setAmountCommitted( ($regfee + $sponsoramount + $donationamount - (100*$ms_registration_value->getIsTeacher()) - $discountamount) );										
			
			if( isset( $_POST['snwc'] ))
			{
				$ms_registration_value->setSpecialNeedsWheelchair(1);
			}
			else
			{
				$ms_registration_value->setSpecialNeedsWheelchair(0);
			}
			
			if( isset( $_POST['snrm'] ))
			{
				$ms_registration_value->setSpecialNeedsRoom(1);
			}
			else
			{
				$ms_registration_value->setSpecialNeedsRoom(0);
			}

			$ms_registration_value->setSpecialRequests($this->input->post('sncomments'));
			
			$ms_registration_value->setAmountPaid($this->input->post('amountpaid'));
			
			$amountcommitted = floatval($ms_registration_value->getAmountCommitted());
			$amountpaid = floatval($ms_registration_value->getAmountPaid());
			
			if (abs($amountcommitted - $amountpaid) > 0.01)
			{
				//Refund
				if (($amountpaid - $amountcommitted) > 0.01)
					$ms_registration_value->setPaymentStatus(3);
				else
					$ms_registration_value->setPaymentStatus(0); //Owed
			}
			else
			{
				//Paid
				$ms_registration_value->setPaymentStatus(1);
			}
			
			$ms_registration_value->setCheckNum($this->input->post('checknum'));
			$ms_registration_value->setPaymentTransactionID($this->input->post('pptxnid'));
/*			
			$objstr_orig = $this->Mahasamadhi_proxy->genMSRegistrationObjectString($ms_registration_value_orig);
			$objstr = $this->Mahasamadhi_proxy->genMSRegistrationObjectString($ms_registration_value);

			$objstrhash_orig = $this->Mahasamadhi_proxy->genMSRegistrationObjectHash($ms_registration_value_orig);
			$objstrhash = $this->Mahasamadhi_proxy->genMSRegistrationObjectHash($ms_registration_value);
			
			echo "O_str: ".$objstr_orig['mrpstr']."</br>";		
			echo "M_str: ".$objstr['mrpstr']."</br>";
			echo "</br>";
			echo "O_hash: ".$objstrhash_orig."</br>";		
			echo "M_hash: ".$objstrhash."</br>";
			echo "</br>";
			echo "</br>";
*/			
			$comparehasharr = $this->Mahasamadhi_proxy->compareMSRegistrationObjects($ms_registration_value_orig,$ms_registration_value);
			//echo "Comparison: ".$comparehasharr['mrh']." , ".$comparehasharr['mrp']." , ".$comparehasharr['mrs']."</br>";		

			echo "<u><b>Editing Registration</b></u></br>";
			echo $ms_registration_value->getRegCode()."</br>";
			echo $ms_registration_value->getFirstName()." ".$ms_registration_value->getLastName()."</br>";
			echo "</br>";
			echo "</br>";

			if (($comparehasharr['mrh'] != 1) or ($comparehasharr['mrp'] != 1) or ($comparehasharr['mrs'] != 1))
			{
				//Update registration
				$this->Mahasamadhi_proxy->updateMahasamadhiRegistration( $ms_registration_value, $comparehasharr );
	
				echo '<font size = "3" color = "red"><b>Successfully Updated</b></font></br>';
			}
			else
			{
				echo '<font size = "3" color = "blue"><b>Update Not Required</b></font></br>';
			}

			die;
		}

		//Get display detailed information for specified registration
		public function ms_registrant_detail( $ms_reg_code, $urlKey )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Person_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			$this->load->model('values/mahasamadhi/Mahasamadhi_registration_value');
			
			$is_logged_in = $this->session->userdata( 'is_logged_in' );
			if (!$is_logged_in)
			{
				redirect( base_url() . 'cmb/member/login_home/' );
			}
		
			$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );
			if ($seckey != $this->session->userdata( 'logged_in_key' ))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}
			
			//Get id for person who logged in
			$loginPersonId = $this->session->userdata( 'person_id' );
			if ( $loginPersonId < 1 )
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			if ((!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "mahasamadhi", "admin" )) and (!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "admin" )) and (!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "superadmin" )))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );				
			}

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$desc = $this->Mahasamadhi_proxy->getEventName( 1 );
			
			$ms_reg_history_id = $this->Mahasamadhi_proxy->getRegIDFromRegCode($ms_reg_code);
			
			//Get registration value object
			$ms_registration_value = Mahasamadhi_registration_value::cast($this->Mahasamadhi_proxy->getRegistrantDetailInfo($ms_reg_history_id));
												
			$data['title'] = ' Registration Detail for Reg Code: '.$ms_reg_code;
			//$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['curyear'] = $this->Mahasamadhi_proxy->getEventYear();
			$data['view'] = 'mahasamadhi/ms_registrant_detail_view';
			$data['ms_registration_value'] = $ms_registration_value;
			$data['loggedinname'] = $this->Person_proxy->getPersonName( $loginPersonId );
			$data['urlKey'] = $urlKey;
						
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		private function getPayPalForm( $ms_registration_value, $qty, $paypalTempId, $desc, $eventID )
		{
			$this->load->library('Paypal_Lib');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			$this->load->model('values/mahasamadhi/Mahasamadhi_registration_value');
			
		    $amount = $ms_registration_value->getTotalRegistrationFee();
			$ppcode = $ms_registration_value->getFirstName()."-".$ms_registration_value->getLastName()."-".$ms_registration_value->getEmail();
			$this->paypal_lib->add_field('return', site_url('/mahasamadhi/mahasamadhi_registration/paypal_success/'.$eventID));
		    $this->paypal_lib->add_field('cancel_return', site_url('/mahasamadhi/mahasamadhi_registration/paypal_cancel/'));
		    $this->paypal_lib->add_field('notify_url', site_url('/mahasamadhi/mahasamadhi_registration/ipn/')); // <-- IPN url
		    $this->paypal_lib->add_field('custom', $paypalTempId); // <-- Verify return
	
		    $this->paypal_lib->add_field('item_name', 'MSC2012-'.$ppcode.'-'.$qty.' persons');
		    $this->paypal_lib->add_field('amount', $amount);
	
		    return $this->paypal_lib->paypal_form();			
		}

		public function ipn()
		{
			$this->load->model('proxies/Paypal_proxy');
			$this->load->library('Paypal_Lib');
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			$this->load->model('values/mahasamadhi/Mahasamadhi_registration_value');

			//$this->Walk_proxy->log_cmb_registration("Entered IPN code");
					
			if ( $this->paypal_lib->validate_ipn() )
			{
				//Paypal validation success
				//$this->Walk_proxy->log_cmb_registration("Valid IPN Request");
			
				$curyear = $this->Mahasamadhi_proxy->getEventYear();

				$ms_registration_value = unserialize($this->Paypal_proxy->getTempData( $this->paypal_lib->ipn_data['custom'] ));
				$ms_registration_value = Mahasamadhi_registration_value::cast( $ms_registration_value );

				$desc = $this->Mahasamadhi_proxy->getEventName( 1 );
				
				//$this->Walk_proxy->log_cmb_registration("TXN ID: ".$this->paypal_lib->ipn_data['txn_id']);
				
				//Insert into 'ms_reg_history'
				$ms_reg_history_id = $this->Mahasamadhi_proxy->insertMSRegistrationPayPal($ms_registration_value, $curyear, $this->paypal_lib->ipn_data['txn_id'], $this->paypal_lib->ipn_response, 1);
				
				if ($ms_reg_history_id > 0)
				{
					$regcode = $this->Mahasamadhi_proxy->getRegCodeFromRegID($ms_reg_history_id);
					
					//Send email confirming payment and registration
					$this->Mahasamadhi_proxy->sendEventRegistrationConfirmEmailPaypal( $ms_registration_value, $regcode, $desc, $curyear, $this->paypal_lib->ipn_data['txn_id']);
					
					//Remove value object from temp table
					$this->Paypal_proxy->removeTempData( $this->paypal_lib->ipn_data['custom'] );
				}
				else
				{
					//Send email for registration failure
					$this->Mahasamadhi_proxy->sendEventRegistrationFailedEmailPaypal( $ms_registration_value, $desc, $curyear, "Error inserting registration record");					
				}
				
				$this->session->unset_userdata('sessionobj_temp_id');
				$this->session->unset_userdata('ms_registration_value');
			}
			else
			{
				//Paypal validation failed
				//$this->Walk_proxy->log_cmb_registration("Valid IPN Request");
			
				if ( array_key_exists("custom",$this->paypal_lib->ipn_data) )
				{
					$curyear = $this->Mahasamadhi_proxy->getEventYear();

					$ms_registration_value = unserialize($this->Paypal_proxy->getTempData( $this->paypal_lib->ipn_data['custom'] ));
					$ms_registration_value = Mahasamadhi_registration_value::cast( $ms_registration_value );
	
					$desc = $this->Mahasamadhi_proxy->getEventName( 1 );
					
					//$this->Walk_proxy->log_cmb_registration("TXN ID: ".$this->paypal_lib->ipn_data['txn_id']);
					
					//Insert into 'ms_reg_history'
					$tmp = $this->Mahasamadhi_proxy->insertMSRegistrationPayPal($ms_registration_value, $curyear, "", $this->paypal_lib->last_error, 0);
					
					//Send email for registration failure
					$this->Mahasamadhi_proxy->sendEventRegistrationFailedEmailPaypal( $ms_registration_value, $desc, $curyear, $this->paypal_lib->last_error);
				}
				else
				{
					$this->Walk_proxy->log_cmb_registration("Paypal custom field not found");					
				}
				
				$this->session->unset_userdata('sessionobj_temp_id');
				$this->session->unset_userdata('ms_registration_value');
			}
		}
		
		public function pay_by_check( $eventID )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Paypal_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			$this->load->model('values/mahasamadhi/Mahasamadhi_registration_value');
			
			$currentyear = $this->Mahasamadhi_proxy->getEventYear();
			
			$paypalTempId = $this->session->userdata('sessionobj_temp_id');
			if ($paypalTempId <= 0)
			{
				redirect( base_url() . 'mahasamadhi/mahasamadhi_registration/registration_error/'.$eventID);
			}
			$ms_registration_value = unserialize($this->session->userdata('ms_registration_value'));				
			$ms_registration_value = Mahasamadhi_registration_value::cast($ms_registration_value);
			
			$total_fee = $ms_registration_value->getTotalRegistrationFee();
			
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			//Insert into 'ms_reg_history'
			$ms_reg_history_id = $this->Mahasamadhi_proxy->insertMSRegistrationCheck($ms_registration_value, $currentyear);

			if ($ms_reg_history_id > 0)
			{
				$regcode = $this->Mahasamadhi_proxy->getRegCodeFromRegID($ms_reg_history_id);

				//Send email to member with instructions on sending the check
				$this->Mahasamadhi_proxy->sendEventRegistrationByCheckEmail( $ms_registration_value, $regcode, $desc, $currentyear );
				
				//Remove temporary entry
				//$this->Walk_proxy->deleteRegTempObj( $paypalTempId );			
				//$this->session->unset_userdata('ms_registration_value');
				
				$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );

				$data['title'] = 'Registration with Payment By Check for '.$desc.' '.$currentyear;
				$data['view'] = 'mahasamadhi/ms_paybycheck_view';
			}
			else
			{
				$data['title'] = 'Already Registered by Check for '.$desc.' '.$currentyear;
				$data['view'] = 'mahasamadhi/ms_registration_failed_view';				
			}
			
			switch ($eventID)
			{
				case 1:
					//$data['msc_menu'] = TRUE;
					$data['msc_header'] = TRUE;
					$data['curyear'] = $currentyear;
					$data['total_fee'] = $total_fee;
					$data['desc'] = $desc;
		
					$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
				break;
			}
		}

		//Admin release checks associated with various events
		public function release_check_event( $urlKey )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			$this->load->model('proxies/Person_proxy');
			
			$is_logged_in = $this->session->userdata( 'is_logged_in' );
			if (!$is_logged_in)
			{
				redirect( base_url() . 'cmb/member/login_home/' );
			}
			
			$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );			
			if ($seckey != $this->session->userdata( 'logged_in_key' ))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			$personId = $this->Person_proxy->getPrimaryPersonID( $urlKey );
			if ( $personId < 1 )
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}
			
			$group = $this->Person_proxy->getPersonGroup( $personId );
			$role = $this->Person_proxy->getPersonRole( $personId );
			
			if (in_array('admin',$role) or in_array('superadmin',$role))
			{
				$curyear = $this->Mahasamadhi_proxy->getEventYear();
				$desc = $this->Mahasamadhi_proxy->getEventName( 1 );
				$regInfo = $this->Mahasamadhi_proxy->getEventUnpaidCheckInfo( $curyear );
				
				if (count($regInfo) > 0)
				{
					$data['title'] = 'Release Checks Received for '.$desc.' '.$curyear;
					//$data['msc_menu'] = TRUE;
					$data['msc_header'] = TRUE;
					$data['curyear'] = $curyear;
					$data['view'] = 'mahasamadhi/ms_release_check_view';
					$data['regInfo'] = $regInfo;
					$data['urlKey'] = $urlKey;
					
					$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
				}
				else
				{
					echo('<b>No Unreleased Transactions</b>');
					die;
				}
			}
			else
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );			
			}
		}

		public function release_check_event_process( $urlKey )
		{
			$this->load->model('proxies/Person_proxy');
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('values/mahasamadhi/Mahasamadhi_registration_value');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			
			$is_logged_in = $this->session->userdata( 'is_logged_in' );
			if (!$is_logged_in)
			{
				redirect( base_url() . 'cmb/member/login_home/' . $urlKey . '/' );
			}

			$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );		
			if ($seckey != $this->session->userdata( 'logged_in_key' ))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			$personId = $this->Person_proxy->getPrimaryPersonID( $urlKey );
			if ( $personId < 1 )
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}
			
			$group = $this->Person_proxy->getPersonGroup( $personId );
			$role = $this->Person_proxy->getPersonRole( $personId );

			$curyear = $this->Mahasamadhi_proxy->getEventYear();

			if (in_array('admin',$role) or in_array('superadmin',$role))
			{
				//Get check info
				$RegIdArray = $this->Mahasamadhi_proxy->getEventUnpaidCheckRegId( $curyear );
				
				for( $i = 0; $i < count($RegIdArray); $i++ )
				{
					$checknum = $this->input->post('msid'.$RegIdArray[$i]);
					$checkamount = $this->input->post('msidca'.$RegIdArray[$i]);
					if ($checknum != "")
					{				
						//Update 'ms_reg_history' for check payment
						$tmp = $this->Mahasamadhi_proxy->completeMSRegistrationCheck($RegIdArray[$i], $checknum, $checkamount);
	
						//Get registration value object
						$ms_registration_value = $this->Mahasamadhi_proxy->getRegistrantDetailInfo($RegIdArray[$i]);
													
						$this->Mahasamadhi_proxy->sendEventRegistrationCheckConfirmEmail( $ms_registration_value, $curyear);
					}
				}
							
				//redirect( base_url() . 'cmb/member/home/' . $urlKey . '/' );
				redirect( base_url() . 'mahasamadhi/mahasamadhi_registration/release_check_event/' . $urlKey . '/' );
			}
			else
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );			
			}
		}

		public function paypal_success( $eventID )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			
			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			switch ($eventID)
			{
				case 1:
					$data['title'] = 'Registration Confirmed for '.$desc.' '.$curyear;
					//$data['msc_menu'] = TRUE;
					$data['msc_header'] = TRUE;
					$data['view'] = 'mahasamadhi/ms_registration_success_view';
					$data['curyear'] = $this->Mahasamadhi_proxy->getEventYear();
					$data['desc'] = $desc;
							
					$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
				break;
			}			
		}

		public function registration_error( $eventID )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			
			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );

			switch ($eventID)
			{
				case 1:
					$data['title'] = 'An error occurred during registration for '.$desc.' '.$curyear;
					$data['msc_menu'] = TRUE;
					$data['msc_header'] = TRUE;
					$data['view'] = 'mahasamadhi/registration_ms_error_view';
					$data['curyear'] = $curyear;
					$data['desc'] = $desc;
					
					$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
				break;
			}			
		}

		public function event_registered( $eventID )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');
			
			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			//echo $desc."</br>";
			
			switch ($eventID)
			{
				case 1:
					$data['title'] = 'Already Registered for '.$desc.' '.$curyear;
					$data['msc_menu'] = TRUE;
					$data['msc_header'] = TRUE;
					$data['view'] = 'mahasamadhi/ms_registered_view';
					$data['curyear'] = $curyear;
					$data['desc'] = $desc;
					
					$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
				break;
			}			
		}

		public function paypal_cancel()
		{
			redirect( base_url() );
			die;
		}

		public function ms_directions()
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = 'Directions for '.$desc.' '.$curyear;
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_directions_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function ms_menu()
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = 'Menu for '.$desc.' '.$curyear;
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_menu_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function ms_contact_us()
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = 'Contacts For '.$desc.' '.$curyear;
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_contact_us_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}
		
		public function topics()
		{		
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = 'Topics for '.$desc.' '.$curyear;
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_topics_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function photos()
		{		
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = 'Photos for '.$desc.' '.$curyear;
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_photos_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function balavihar()
		{		
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = 'Balavihar Camp for '.$desc.' '.$curyear;
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_balavihar_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function chyk()
		{		
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = 'CHYK Camp for '.$desc.' '.$curyear;
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_chyk_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function chyk_schedule()
		{		
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = 'Schedule for CHYK Camp';
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_chyk_schedule_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function fees()
		{		
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = 'Fees for '.$desc.' '.$curyear;
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_fees_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function videos()
		{		
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = 'Videos for '.$desc.' '.$curyear;
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_videos_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}
		
		public function swamiji()
		{		
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = 'About Swami Swaroopanandaji';
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_swamiji_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function highlights()
		{		
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = '';
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_highlights_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function schedule()
		{		
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$data['title'] = $desc.' '.$curyear.' Camp Schedule';
			$data['msc_menu'] = TRUE;
			$data['msc_header'] = TRUE;
			$data['view'] = 'mahasamadhi/ms_schedule_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function register_offline()
		{		
			$this->load->view('mahasamadhi/ms_download_form_view');
		}

		//Update registration object hash codes
		public function admin_update_ms_registrations_hash()
		{		
			$this->load->model('proxies/mahasamadhi/Mahasamadhi_proxy');

			$curyear = $this->Mahasamadhi_proxy->getEventYear();
			$eventID = 1;
			$desc = $this->Mahasamadhi_proxy->getEventName( $eventID );
			
			$msregidarr = $this->Mahasamadhi_proxy->getAllMSRegID( $curyear );
			
			$numreg = count($msregidarr);
			echo "Found ".$numreg." Registrations</br>";
			
			for($i=0; $i<$numreg; $i++)
			{
				$ms_registration_value = $this->Mahasamadhi_proxy->getRegistrantDetailInfo( $msregidarr[$i] );
				$regobjhash = $this->Mahasamadhi_proxy->genMSRegistrationObjectHash( $ms_registration_value );
				$tmp = $this->Mahasamadhi_proxy->updateMSRegistrationObjectHash( $msregidarr[$i], $regobjhash );
			}
			
			die;
		}
	}
?>